function fig = fm_themefig()
% FM_THEMEFIG create GUI for PSAT theme selection
%
% HDL = FM_THEMEFIG()
%
%see also FM_THEME
%
%Author:    Federico Milano
%Date:      11-Nov-2002
%Version:   1.0.0
%
%E-mail:    Federico.Milano@uclm.es
%Web-site:  http://www.uclm.es/area/gsee/Web/Federico
%
% Copyright (C) 2002-2013 Federico Milano

global Settings Theme Fig

if Fig.theme, figure(Fig.theme), return, end
if usejava('desktop') && ispc
  fm_choice('Theme GUI can be used on Windows only if the Java Desktop is disabled.',2)
  return
end
if strcmp(Settings.platform,'MAC')
  fm_choice('Theme GUI can be used on Mac Os X only if the Java Desktop is disabled.',2)
  return
end

colori = [     0         0    1.0000;
               0    0.5000         0;
          1.0000         0         0;
               0    0.7500    0.7500;
          0.7500         0    0.7500;
          0.7500    0.7500         0;
          0.2500    0.2500    0.2500];

h0 = figure('Units','normalized', ...
	    'CreateFcn','Fig.theme = gcf;', ...
	    'DeleteFcn','Fig.theme = 0;', ...
	    'Color',Theme.color01, ...
	    'Colormap',[], ...
	    'MenuBar','none', ...
	    'FileName', 'fm_themefig', ...
	    'Name','Theme Editor', ...
	    'NumberTitle','off', ...
	    'PaperPosition',[18 180 576 432], ...
	    'PaperUnits','points', ...
	    'Position',sizefig(0.6934,0.6380), ...
	    'ToolBar','none');

colormap(hsv(64))

Theme.hdl(1,1) = axes('Parent',h0, ...
		      'AmbientLightColor',Theme.color01, ...
		      'Box','on', ...
		      'CameraUpVector',[0 1 0], ...
		      'Color',Theme.color01, ...
		      'ColorOrder',colori, ...
		      'Position',[0.3648 0.0592 0.5789 0.8694], ...
		      'Tag','Axes1', ...
		      'XColor',[0 0 0], ...
		      'XTickMode','manual', ...
		      'YColor',[0 0 0], ...
		      'YTickMode','manual', ...
		      'ZColor',[0 0 0]);
Theme.hdl(2,1) = uicontrol('Parent',h0, ...
			   'Units','normalized', ...
			   'CreateFcn','fm_theme themes', ...
			   'Callback', 'fm_theme preview', ...
			   'BackgroundColor',Theme.color03, ...
			   'ForegroundColor',Theme.color06, ...
			   'FontName',Theme.font01, ...
			   'Position',[0.0549 0.4102 0.2437 0.4673], ...
			   'String','Default', ...
			   'Style','listbox', ...
			   'Tag','Listbox1', ...
			   'Value',1);
h1 = uicontrol('Parent',h0, ...
	       'Units','normalized', ...
	       'Enable','inactive', ...
	       'BackgroundColor',Theme.color02, ...
	       'ForegroundColor',Theme.color03, ...
	       'Position',[0.0549 0.0592 0.2437 0.3133], ...
	       'Style','frame', ...
	       'Tag','Frame1');
h1 = uicontrol('Parent',h0, ...
	       'Units','normalized', ...
	       'Callback','fm_theme apply', ...
	       'BackgroundColor',Theme.color03, ...
	       'FontWeight','bold', ...
	       'ForegroundColor',Theme.color09, ...
	       'Position',[0.0952 0.2783 0.1592 0.0633], ...
	       'String','Apply', ...
	       'Tag','Pushbutton1');
h1 = uicontrol('Parent',h0, ...
	       'BackgroundColor',Theme.color02, ...
	       'Callback','fm_theme preview', ...
	       'Units','normalized', ...
	       'Position',[0.0952 0.1842 0.1592 0.0633], ...
	       'String','Preview', ...
	       'Tag','Pushbutton1');
h1 = uicontrol('Parent',h0, ...
	       'BackgroundColor',Theme.color02, ...
	       'Callback','close(gcf)', ...
	       'Units','normalized', ...
	       'Position',[0.0952 0.0900 0.1592 0.0633], ...
	       'String','Close', ...
	       'Tag','Pushbutton1');
Theme.hdl(3,1) = uicontrol('Parent',h0, ...
			   'Units','normalized', ...
			   'BackgroundColor',Theme.color01, ...
			   'HorizontalAlignment','left', ...
			   'Position',[0.0549    0.8878    0.2366    0.0408], ...
			   'String','Themes', ...
			   'Style','text', ...
			   'Tag','StaticText1');
Theme.hdl(4,1) = uicontrol('Parent',h0, ...
			   'Units','normalized', ...
			   'Enable','inactive', ...
			   'BackgroundColor',Theme.color02, ...
			   'ForegroundColor',Theme.color03, ...
			   'Position',[0.3915 0.0939 0.5282 0.2633], ...
			   'Style','frame', ...
			   'Tag','Frame1');
Theme.hdl(5,1) = uicontrol('Parent',h0, ...
			   'Units','normalized', ...
			   'Enable','inactive', ...
			   'BackgroundColor',Theme.color03, ...
			   'FontWeight','bold', ...
			   'ForegroundColor',Theme.color09, ...
			   'Position',[0.4437 0.1857 0.1676 0.0612], ...
			   'String','Button 2', ...
			   'Tag','Pushbutton3');
Theme.hdl(6,1) = uicontrol('Parent',h0, ...
			   'Units','normalized', ...
			   'Enable','inactive', ...
			   'BackgroundColor',Theme.color02, ...
			   'Position',[0.4099 0.2694 0.1676 0.0612], ...
			   'String','Button 1', ...
			   'Tag','Pushbutton2');
Theme.hdl(7,1) = axes('Parent',h0, ...
		      'Box','on', ...
		      'CameraUpVector',[0 1 0], ...
		      'Color',Theme.color11, ...
		      'ColorOrder',colori, ...
		      'Position',[0.7183    0.4327    0.1662    0.1816], ...
		      'Tag','Axes2', ...
		      'XColor',[0 0 0], ...
		      'XGrid','on', ...
		      'XTick',[0 0.25 0.5 0.75 1], ...
		      'XTickMode','manual', ...
		      'YColor',[0 0 0], ...
		      'YGrid','on', ...
		      'YTick',[0 0.25 0.5 0.75 1], ...
		      'YTickMode','manual', ...
		      'ZColor',[0 0 0], ...
		      'ZTick',[0 0.5 1], ...
		      'ZTickMode','manual');
Theme.hdl(8,1) = uicontrol('Parent',h0, ...
			   'Units','normalized', ...
			   'Enable','inactive', ...
			   'FontName',Theme.font01, ...
			   'ForegroundColor',Theme.color06, ...
			   'BackgroundColor',Theme.color03, ...
			   'Position',[0.3958 0.4694 0.1704 0.4102], ...
			   'String',{'Listbox 2';' ';'item 1';'item 2';'item 3';'...'}, ...
			   'Style','listbox', ...
			   'Tag','Listbox2', ...
			   'Value',5);
Theme.hdl(9,1) = uicontrol('Parent',h0, ...
			   'Units','normalized', ...
			   'FontName',Theme.font01, ...
			   'ForegroundColor',Theme.color05, ...
			   'Enable','inactive', ...
			   'BackgroundColor',Theme.color04, ...
			   'HitTest','off', ...
			   'Position',[0.4690 0.3918 0.1718 0.4122], ...
			   'String',{'Listbox 1';' ';'item 1';'item 2';'item 3';'...'}, ...
			   'Style','listbox', ...
			   'Tag','Listbox2', ...
			   'Value',5);
Theme.hdl(10,1) = uicontrol('Parent',h0, ...
			    'Enable','inactive', ...
			    'Units','normalized', ...
			    'BackgroundColor',Theme.color02, ...
			    'Position',[0.7113 0.1959 0.1761 0.0490], ...
			    'String','Checkbox', ...
			    'Style','checkbox', ...
			    'Value',1, ...
			    'Tag','Checkbox1');
Theme.hdl(11,1) = uicontrol('Parent',h0, ...
			    'Units','normalized', ...
			    'Enable','inactive', ...
			    'BackgroundColor',Theme.color02, ...
			    'Position',[0.7437    0.1204    0.1592    0.0490], ...
			    'String','Radio Button', ...
			    'Style','radiobutton', ...
			    'Value',1, ...
			    'Tag','Radiobutton1');
Theme.hdl(12,1) = uicontrol('Parent',h0, ...
			    'Units','normalized', ...
			    'Enable','inactive', ...
			    'BackgroundColor',Theme.color02, ...
			    'ForegroundColor',Theme.color03, ...
			    'Position',[0.6873 0.6633 0.2211 0.2224], ...
			    'Style','frame', ...
			    'Tag','Frame2');
Theme.hdl(13,1) = uicontrol('Parent',h0, ...
			    'Units','normalized', ...
			    'Enable','inactive', ...
			    'FontName',Theme.font01, ...
			    'ForegroundColor',Theme.color07, ...
			    'BackgroundColor',Theme.color04, ...
			    'HorizontalAlignment','left', ...
			    'Position',[0.7732    0.6898    0.1099    0.0469], ...
			    'String','Text 3', ...
			    'Style','edit', ...
			    'Tag','EditText1');
Theme.hdl(14,1) = uicontrol('Parent',h0, ...
			    'Units','normalized', ...
			    'Enable','inactive', ...
			    'BackgroundColor',Theme.color04, ...
			    'FontName',Theme.font01, ...
			    'ForegroundColor',Theme.color05, ...
			    'HorizontalAlignment','left', ...
			    'Position',[0.7127    0.7551    0.1169    0.0469], ...
			    'String','Text 2', ...
			    'Style','edit', ...
			    'Tag','EditText1');
Theme.hdl(15,1) = uicontrol('Parent',h0, ...
			    'Units','normalized', ...
			    'Enable','inactive', ...
			    'BackgroundColor',Theme.color02, ...
			    'Position',[0.7113 0.8204 0.1732 0.0490], ...
			    'String','Text 1', ...
			    'Style','text', ...
			    'Tag','StaticText2');
Theme.hdl(16,1) = uicontrol('Parent',h0, ...
			    'Units','normalized', ...
			    'Enable','inactive', ...
			    'BackgroundColor',Theme.color04, ...
			    'FontName',Theme.font01, ...
			    'ForegroundColor',Theme.color05, ...
			    'Position',[0.6662 0.2878 0.2042 0.0388], ...
			    'String','Popup Menu', ...
			    'Style','popupmenu', ...
			    'Tag','PopupMenu1', ...
			    'Value',1);
Theme.hdl(17,1) = uicontrol('Parent',h0, ...
			    'Units','normalized', ...
			    'Enable','inactive', ...
			    'BackgroundColor',Theme.color08, ...
			    'ForegroundColor',Theme.color08, ...
			    'HorizontalAlignment','left', ...
			    'Position',[0.4042    0.1082    0.2732    0.0531], ...
			    'String','Bar', ...
			    'Style','frame', ...
			    'Tag','Frame3');
Theme.hdl(18,1) = uicontrol('Parent',h0, ...
			    'Units','normalized', ...
			    'BackgroundColor',Theme.color08, ...
			    'ForegroundColor',[0 0 0], ...
			    'Position',[0.4225 0.1184 0.2352 0.0327], ...
			    'String','bar', ...
			    'Style','text', ...
			    'Tag','StaticText3');

if sum(Theme.color08)/3 < 0.33, set(Theme.hdl(18),'ForegroundColor',[1 1 1]); end

if nargout > 0, fig = h0; end